"웹 폰트와 아이콘은 웹 페이지의 '얼굴'과 '표정'을 담당해요. 예쁜 폰트와 센스 있는 아이콘으로 우리 앱을 더 매력적으로 만들 수 있죠."
Google Fonts와 같은 서비스를 이용해 원하는 글꼴을 쉽게 적용할 수 있습니다.
<link> 태그를 index.html에 추가하는 방법
<link>
index.html
<head>
font-family
<!-- client/index.html --> <head> <link rel="preconnect" href="https://fonts.googleapis.com"> <link rel="preconnect" href="https://fonts.gstatic.com" crossorigin> <link href="https://fonts.googleapis.com/css2?family=Noto+Sans+KR:wght@400;700&display=swap" rel="stylesheet"> </head>
/* client/src/assets/css/main.css */ body { font-family: 'Noto Sans KR', sans-serif; }
Font Awesome과 같은 라이브러리를 사용하면 간단한 태그로 아이콘을 표시할 수 있습니다.
CDN을 이용한 방법
<script>
<i>
<!-- client/index.html --> <head> ... <script src="https://kit.fontawesome.com/your-kit-code.js" crossorigin="anonymous"></script> </head> <!-- 컴포넌트 템플릿 --> <button type="button"> <i class="fas fa-search"></i> 조회 </button>
미리 정의된 CSS 클래스 모음으로, 일관성 있는 UI를 빠르게 만들 수 있도록 도와줍니다.
유틸리티 우선 (Utility-First)
<div class="p-4 bg-blue-100 rounded">...</div>
컴포넌트 기반 (Component-Based)
<button class="btn btn-primary">Primary Button</button>
HandStack에서는 Libman을 통해 이러한 프레임워크를 쉽게 설치하고 관리할 수 있습니다.
Libman
"이제 우리 앱은 기능뿐만 아니라 '겉모습'도 여러분의 손으로 직접 만들어갈 수 있게 되었어요! 나만의 개성을 담은 앱을 만들어 보세요."
client/src/assets/css/main.css 파일은 프로젝트 전체에 적용되는 스타일을 정의합니다.
client/src/assets/css/main.css
CSS 변수를 사용하면 앱의 핵심 색상, 폰트 등을 한 곳에서 관리하여 테마 변경이 쉬워집니다.
핸즈온
main.css
:root
var(--변수명)
/* client/src/assets/css/main.css */ :root { --primary-color: #007bff; --text-color: #212529; --background-color: #ffffff; --base-font-size: 16px; } body { color: var(--text-color); background-color: var(--background-color); font-size: var(--base-font-size); }
Vue.js는 <style scoped>를 지원하여 CSS가 해당 컴포넌트 내에서만 적용되도록 합니다.
<style scoped>
이는 다른 컴포넌트와의 스타일 충돌을 막아주어 유지보수를 쉽게 만듭니다.
Guestbook.vue
<!-- GuestbookItem.vue --> <template> <div class="guestbook-item">...</div> </template> <style scoped> /* 이 스타일은 GuestbookItem 컴포넌트 안에서만 적용됩니다. */ .guestbook-item { padding: 1rem; margin-bottom: 0.5rem; background-color: #f8f9fa; border-left: 4px solid var(--primary-color); } </style>
"코드 분할은 마치 대형마트에 물건을 전부 진열하지 않고, 필요한 물건만 그때그때 창고에서 가져오는 것과 같아요. 마트가 훨씬 빨리 열리고, 고객도 원하는 물건을 더 빨리 찾을 수 있죠."
왜 성능 최적화가 중요한가?
문제점
해결책: 코드 분할 (Code Splitting)
HandStack의 프론트엔드 빌드 도구는 자동으로 코드 분할을 지원합니다.
배포용 빌드 시, 코드를 최적화하고 여러 개의 작은 파일(chunk)로 나누어줍니다.
bundling CLI 명령어를 통해 이 과정을 수동으로 실행하고 확인할 수 있습니다.
bundling
npx bundling
dist
# 프로젝트 루트 디렉터리에서 실행 npx bundling
무엇을 배웠나요?
다음 단계
syn.controls.js
여러분은 이제 기능, 디자인, 성능까지 고려하는 프론트엔드 개발의 첫걸음을 떼었습니다.